package com.ma.chapter4.t5;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

import static com.ma.util.Sleeper.sleep;

/**
 * @ClassName TestParkUnpark
 * @Author: mayongqiang
 * @DATE 2022/3/12 19:36
 * @Description:
 */

@Slf4j(topic = "m.TestParkUnpark")
public class TestParkUnpark {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            log.debug("start..");
            sleep(1);
            log.debug("park....");
            LockSupport.park();
            sleep(2);
            LockSupport.park();
            log.debug("resume...");
        }, "t1");
        t1.start();
        sleep(2);
        log.debug("unpark..");
        LockSupport.unpark(t1);
    }
}
